<template>
  <div id="target">  

      <div  style="display:flex;margin-bottom:10px;align-items: center;">
            <img class="top_img" src="@/assets/images/a8.png" style="width:35px;height:35px;margin-right:10px;"/>
            <div style="line-height: 40px;font-weight:bold:">目标管理</div>
     </div> 

 <el-form ref="form" :model="form" label-width="80px"> 
     <div style="display:flex;">
          <div style="flex:1;display:flex;align-items: center;">

          <div style="width:50px;text-align-last: justify;margin-top:-12px;font-size: 14px;color: #606266;margin-right:0px;">查询项</div>
            <el-form-item label="账户查询">
              <el-input v-model="form.phone" placeholder="姓名/手机号"  style="width:160px;"></el-input>
            </el-form-item>

            <div class="buttoon_box">
                <div class="buttoon_box_item"  style="margin-left:10px;background:#FFC600;color:white;" @click="soure_but1()">确 定</div>
                <div class="buttoon_box_item" style="margin-left:10px;border:1px solid #D9D9D9;"  @click="sx_but()">清 空</div>    
            </div>

         </div>

     </div>

     <div style="display:flex;align-items: center;">
            <div style="width:50px;text-align-last: justify;margin-top:-8px;font-size: 14px;color: #606266;margin-right:0px;">筛选项</div> 

            <el-form-item label="是否达成">
                <el-select  v-model="form.select_num" placeholder="请选择" style="width:160px;" disabled>
                    <el-option  v-for="(item,index) in select_data" :key="index" :label="item.name" :value="item.id"  ></el-option>
                </el-select>
            </el-form-item>
 
            <div class="buttoon_box">
                <div class="buttoon_box_item"  style="margin-left:10px;background:#FFC600;color:white;" @click="soure_but1">确 定</div>
                <div class="buttoon_box_item" style="margin-left:10px;border:1px solid #D9D9D9;" @click="sx_but">清 空</div>    
            </div>
     </div>
   </el-form>
  <el-row>
        <el-col :span="24" style="text-align: right;">         
            <el-button type="primary" class="custom_color_button1" style="margin-bottom:10px;"  @click="fictitious_but()">
              <img class="custom_color_button1_img" src="@/assets/images/but_bg2.png"/>添加考核
            </el-button>         
        </el-col>
  </el-row>

  


   <!-- 渲染数据list -->
   <target-list :datalist="datalist" @up_list_fun="list_fun"> </target-list>

   <div style="margin-top:20px;text-align: center;">
      <el-pagination
        background
        @current-change="handleCurrentChange"
        :page-size="10"  
        layout="prev, pager, next, jumper"
        :total="count">
      </el-pagination>
    </div>


   
     <!-- 添加考核 -->
        <el-dialog title="添加考核" :visible.sync="fictitious_mtk"  width="500px">
            <div style="width:100%;"> 

           <el-form ref="form"  label-width="80px">  
                <el-row>   
                    <el-col :span="24" style="display:flex;">
                        <el-form-item label-width="0px" >
                            <el-input v-model="fictitious_form.phone" placeholder="手机号" class="search"></el-input>
                        </el-form-item>

                        <div class="custom_button" @click="fictitious_search()"></div>
                    </el-col>               
                </el-row>
                 <div style="width:100%;" v-if="fictitious_form.show"> 

                    <div style="display:flex;align-items: center;margin-top:10px;">       
                        <div class="box1" >帐号</div>
                        <div style="padding:0px 15px;"></div>
                        <div class="box1" >所属团队</div>
                    </div>

                    <div style="display:flex;align-items: center;margin-top:10px;">
                     
                    <div class="box">
                     
                        <img  v-if="conter.self_icon"  style="width: 50px; height: 50px" :src="urlimg + conter.self_icon" /> 
                           <img  v-else src="@/assets/images/login_bg1.png" />
                        <div class="box_item">
                            <span>{{ conter.self_username }}</span>
                            <span>{{ conter.self_telphone }}</span>
                        </div>
                    </div>

                    <div style="padding:0px 15px;"><i class="el-icon-right"></i></div>

                    <div class="box">                      
                        <img v-if="conter.team_icon"  style="width: 30px; height: 30px" :src="urlimg + conter.team_icon" /> 
                        <img  v-else src="@/assets/images/login_bg1.png" />
                        <div class="box_item">
                            <span>{{ conter.team_username }}</span>
                            <span>{{ conter.team_telphone }}</span>
                        </div>
                    </div>

                  </div>

                    <el-form-item label="新增数量" style="margin-top:10px;">
                        <el-input v-model="fictitious_form.number" placeholder="必填"></el-input>
                    </el-form-item>
                    <el-form-item  label="选择权限" >
                      <el-select  v-model="fictitious_form.select_num_zy" placeholder="请选择蜂巢" style="width:100%;">
                          <el-option  v-for="(item,index) in select_data_zy" :key="index" :label="item.title" :value="item.maid"></el-option>
                      </el-select>
                    </el-form-item>
                    <el-form-item  label="完成区间"  >
                          <div style="display: flex;">
                                <el-date-picker  type="date"   placeholder="开始日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd"  v-model="fictitious_form.start" style="felx:1;"></el-date-picker>
                                <div style="width:20px;height:40px;line-height:40px;text-align: center;"> - </div>
                                <el-date-picker  type="date"   placeholder="结束日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd"  v-model="fictitious_form.end" style="felx:1;"></el-date-picker>
                          </div>
                    </el-form-item>

                    <div style="text-align: center;width:50%;margin:auto;margin-top:30px;">
                          <el-button type="primary" class="custom_color_button" style="width:100%;" @click="fictitious_qr_but()">确认</el-button>
                    </div>
                
               </div>
            </el-form>

         

            </div> 
        </el-dialog>
    
    
      
  </div>
</template>

<script>
import TargetList from '@/view/Member/TargetList'
export default {
  name: 'target',
  data () {
    return {
        datalist:[{"name":"aaaa"}],
        page:1,
        count:0,
        form:{
             phone:'',
             select_num:1
        },
        select_data:[{"id":1,"name":"已达成"},{"id":2,"name":"未达成"}],
        select_data_zy:[],
        fictitious_mtk:false,
        fictitious_form:{
           phone:'',
           number:'',
            start:'',
            end:'',
            select_num_zy:'',
           show:false,
        },
        conter:{
          self_icon:'',
          self_telphone:'',
          self_uid:'',
          self_username:'',
          team_icon:'',
          team_telphone:'',
          team_username:'',
        }
    }
  },
 components:{
    TargetList
  },
  created(){
    this.list_fun()
    this.list_zy()
  },
  mounted (){
    
  },
  methods: {
      list_zy(){
        this.post("/manor/manorOption", {
         
        }).then(res => { 
            this.select_data_zy = res.result     
            //console.log(this.select_data_zy)                  
        })
      },
      list_fun(){
          this.post("/target/listOfData", {
              page:this.page, 
              account:this.form.phone
	        }).then(res => {
            this.count = res.result.count
            this.datalist = res.result.list
            console.log(res)
         })
      },
      mtk1_but(){
        this.mtk1 = true
      },
      fictitious_but(){
         this.fictitious_mtk = true
     },
     fictitious_search(){
        this.post("/goldbean/selectDetails", {
              telphone:this.fictitious_form.phone,
	        }).then(res => {
              //console.log(res)
              if(res.error_code == 0){
                        this.fictitious_form.show = true
                        this.conter.self_icon = res.result.self_icon
                        this.conter.self_telphone = res.result.self_telphone
                        this.conter.self_uid = res.result.self_uid
                        this.conter.self_username = res.result.self_username
                        this.conter.team_icon = res.result.team_icon
                        this.conter.team_telphone = res.result.team_telphone
                        this.conter.team_username =res.result.team_username
                }else {
                      this.open1(res.message,'warning')
                      this.conter={
                            self_icon:'',
                            self_telphone:'',
                            self_uid:'',
                            self_username:'',
                            team_icon:'',
                            team_telphone:'',
                            team_username:'',
                        }
                      this.fictitious_form.show = false
             }
         })
     },
      fictitious_qr_but(){

        this.post("/target/createTarget", {
               uid:this.conter.self_uid,
               news_num:this.fictitious_form.number,
               maid:this.fictitious_form.select_num_zy,
               starttime:this.fictitious_form.start,
               endtime:this.fictitious_form.end,
	        }).then(res => {
                //console.log(res)
             if(res.error_code == 0){
                        this.open1(res.result,'success') 
                        this. conter={
                            self_icon:'',
                            self_telphone:'',
                            self_uid:'',
                            self_username:'',
                            team_icon:'',
                            team_telphone:'',
                            team_username:'',
                        }
                        this.fictitious_form={
                            phone:'',
                            number:'',
                            start:'',
                            end:'',
                            select_num_zy:'',
                            show:false,
                        },
                        this.fictitious_mtk = false
                        this.list_fun()
                }else {
                      this.open1(res.message,'warning') 
                }

         })
        
      },
      soure_but1(){
           this.page == 1
           this.list_fun()
      },
      soure_but2(){
          this.page == 1
           this.list_fun()
      },
      sx_but(){
           this.form={
             phone:'',
             select_num:1
           },
          this.page == 1
          this.list_fun()
      },
     handleSizeChange(val) {
        console.log(`每页 ${val} 条`);
      },
      handleCurrentChange(val) {
        this.page = val
        this.list_fun()
        console.log(`当前页: ${val}`);
      }
  }
}
</script>


<style scoped>
.box{
    width: 200px;
    display: flex;
    border: 1px solid #DCDFE6;
    border-radius: 5px;
    padding:10px;
}
.box1{
    width: 200px;
    display: flex;
    padding:0px 10px;
    text-align: center;
}
.box>img{
    width: 50px;
    height: 50px;
    border-radius: 50%;
}
.box_item{
    flex: 1;
    margin-left:10px;
}
.box_item>span{
   display: block;
}
</style>
